home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
dskut
/
pdisk.zip
/
DOTRANS.ASM
< prev
next >
Wrap
Assembly Source File
|
1989-01-12
|
2KB
|
118 lines
PAGE 64D,132D ; make line length 132
SUBTTL Read and Write sectors
% .MODEL memmodel,C
; .286
.radix 16
OK186 EQU (@Cpu and 02)
IFE @DataSize
EXTRN master_boot_rec:Word, part_boot_rec:Word ; actually ptrs
EXTRN fixed_disk:BYTE, _numsecs:BYTE, _shprod:WORD
Else
RDPART_DATA Segment Para 'FAR_DATA'
EXTRN master_boot_rec:Dword, part_boot_rec:Dword ; actually ptrs
EXTRN fixed_disk:BYTE, _numsecs:BYTE, _shprod:WORD
RDPART_DATA ENDS
Endif
.code
Assume DS:RDPART_DATA
; int dotrans(dword relsect, word startsec, char *buf, char sects, char op);
dotrans PROC Uses ES DI,relseclow,relsechigh,startsec,buf:ptr,sects:byte,op:byte
IF @DataSize
push ds
mov ax,SEG master_boot_rec
mov ds,ax
Endif
MOV AX,relseclow
MOV DX,relsechigh
ADD AX,startsec ; offset of starting sector
ADC DX,0
DIV [_shprod] ; secs_per_track*heads_per_cyl
MOV CH,AL
IF OK186
SHL AH,6
ELSE
MOV CL,6
SHL AH,CL
ENDIF
MOV CL,AH
MOV AX,DX
DIV [_numsecs] ; secs_per_track
MOV DH,AL
INC AH ; sector number is 1 based, not 0 based (from MOD)
OR CL,AH
MOV DL,[fixed_disk]
MOV AL,sects
MOV AH,op
IFE @DataSize
MOV AX,DS
MOV ES,AX
MOV BX,buf
Else
LES BX,buf
Endif
INT 13
mov ax,0
jnc @f
mov ax,-1
@@:
IF @DataSize
pop ds
Endif
RET
dotrans ENDP
boot_transfer proc USES ES DI, mode:Byte, idx
IFE @DataSize
mov ax,ds
mov es,ax
Else
push ds
mov ax,SEG master_boot_rec
mov ds,ax
Endif
mov dl,fixed_disk
mov di,idx
or di,di
jz domaster
dec di
shl di,1
IFE @DataSize
mov bx,[di].part_boot_rec ; but ptrs are only 2 bytes wide
shl di,1
Else
shl di,1 ; ptrs are 4 bytes wide
les bx,[di].part_boot_rec
Endif
shl di,1 ; boot parm table in master_boot_rec is 0x10 bytes wide
shl di,1
add di,Word Ptr [master_boot_rec]
IF @DataSize
mov ds,Word Ptr [master_boot_rec+2]
Endif
mov cx,word ptr [di+1be+2]
mov dh,byte ptr [di+1be+1]
jmp short @F
domaster:
IFE @DataSize
mov bx,[master_boot_rec]
Else
les bx,[master_boot_rec]
Endif
mov cx,1
xor dh,dh
@@:
mov ah,mode
mov al,1 ; read/write 1 sector
int 13
mov ax,0
jnc @f
mov ax,-1
@@:
IF @DataSize
pop ds
Endif
ret
boot_transfer endp
END